package com.lili.store.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.model.store.SelectStore;
import com.lili.common.bean.ResultBean;
import com.lili.common.controller.BaseController;
import com.lili.store.service.SelectStoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/back/store")
@Api(tags = "后台店铺")
public class SelectStoreController extends BaseController {

    @Autowired(required = false)
    SelectStoreService selectStoreService;


    @GetMapping("/select")
    @ApiOperation("查询店铺")
    public ResultBean listselect(){
        List<SelectStore> list = selectStoreService.listselect();
        return success("商铺列表",list);
    }

    @PostMapping("/query")
    @ApiOperation("查询店铺")
    public ResultBean queryByPage(@RequestBody Map map){
        int current = 1;
        int size = 2;
        if(map.get("current")!=null){
            current = Integer.parseInt(map.get("current").toString());
        }
        if(map.get("size")!=null){
            size = Integer.parseInt(map.get("size").toString());
        }
        Page<SelectStore> page = selectStoreService.queryByPage(current,size);
        return success("商铺列表",page);
    }
}
